Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
None
Purpose of change
Fixes #52284 and fixes #49392.
This is part 2 of the monstergroup behaviour changes. The purpose is to allow monster groups to contain subgroups for spawn definitions.
Describe the solution
See #52288 for part 1 of these modifications, otherwise these fields won't make sense.
In monster groups, within the
"monsters"
array, you can define"group"
objects as well as"monster"
objects. Groups use the same fields as monsters, but they are processed differently. When the game looks for possible spawns from a monster group, it will recursively check subgroups if they exist. The weight of the subgroup is defined just like monster objects, so spawn chances only matter for top-level objects. Example:In that example, if the spawn rng chooses a weight of 200, a monster from the
GROUP_MI-GO_SCOUT_TOWER
subgroup will be selected. The selection follows a recursive model, so if that subgroup has its own subgroups, then the rng could select a monster from a subgroup of a subgroup.The magic in this solution is
MonsterGroupEntry::group
andMonsterGroupEntry::is_group()
. This means that we can no longer assume that a MonsterGroupEntry is a monster. It could also be a monster group.Describe alternatives you've considered
The monstergroup loader could be converted to use a similar model to itemgroups, but it's drastically different and would involve some project-wide refactoring.
Testing
Added the following subgroup to
"GROUP_ZOMBIE"
:After visiting a city, scorched zombies from the subgroup spawned with the regular zombies:
Additional context
Some additional catch-up changes will be needed once part 1 is merged: